﻿using Sustainalytics.Entities;
using Sustainalytics.Utils;
using System;
using System.Collections.Generic;

namespace Sustainalytics.DataLayer
{
    public enum InvalidSynUserType
    {
        All,
        NullEmail,
        Duplicate
    }

    public interface IAccountsRepository
    {
        void Cleanup();

        List<Account> GetAccounts(Status? status, string searchText, ListOptions listOptions, bool tier1_or_tier2 = false);

        int GetAccountsTotalCount(Status? status, string searchText, bool tier1_or_tier2 = false);

        Account GetAccountById(Guid id);
        Account TryGetAccountById(Guid id);


        List<Guid> ListAccountsIds();

        void DeactivateAccounts(List<Guid> accountsIds, DateTime currentSyncDate);

        void SaveAccount(Account account);

        void SaveAccounts(List<Account> accounts);

        int GetUsersByAccountIdTotalCount(Status? status, Guid accountId);

        void SaveUsers(List<User> users);

        void SaveClientUsers(List<ClientUser> clientUsers);

        void SavePasswordByUserId(Guid userId, string password, DateTime expirationDate);

        void SavePasswordByUsername(string username, string password, DateTime expirationDate);

        User GetUserByUserId(Guid userId);

        User TryGetUserByUserId(Guid userId);

        bool VerifyUserExists(Guid userId);

        User GetUserByUsername(string username);

        User TryGetUserByUsername(string username);

        ClientUser GetClientUserByUserId(Guid userId);

        ClientUser TryGetClientUserByUserId(Guid userId);

        ClientUser GetClientUserByUsername(string username);

        void UpdateAccountNameForUsers(Account account);

        void UpdateAccountNameForFakeIPUsers(Account account);

        DateTime GetLastSyncDate(SyncType syncType);

        void SaveLastSync(Synchronization lastSync);

        List<Guid> ListUsersIds(bool filterDeleted);

        int DeleteUsers(List<Guid> list);

        void SaveUser(User user);

        List<User> GetDirtyUsers(bool filterDeleted);

        List<Guid> GetAccountsByModifiedAfter(DateTime dateTime);

        List<User> GetUsersByAccountId(Guid accountId, bool filterDeleted);

        List<User> GetUsers(List<Guid> accountIds, Status? status, string searchText, ListOptions listOptions);
        int GetUsersTotalCount(List<Guid> accountIds, Status? status, string searchText);
        List<Account> GetAccountsByUserSatusAndSearchFilter(Status? userStatus, string filterText);

        List<ReactivatedSyncEvent> GetReactivatedSyncEvents(int skip, int take);

        void SaveReactivatedSyncEvents(List<ReactivatedSyncEvent> syncEvents);


        void DeleteReactivatedSyncEvent(Guid id);

        List<Guid> ListAccountsByIdAndStatus(List<Guid> list, Status status);
        List<Account> GeAccountsByUpcomingEsgProfiles();
        void UpdateCurrentEsgProfile(Account profile);

        List<Guid> GetInvalidSyncUsers(InvalidSynUserType type);

        void DeleteInvalidSyncUsers(List<Guid> users);

        void SaveInvalidSyncUsers(List<User> users);

        List<Account> GetAccountsByds(List<Guid> ids = null);

        List<Account> GetAccountsIncludingNameOnly(Status status, bool hasPlatformAccess);
    }
}
